package com.mxj.indexer.core;

import lombok.Data;

import java.util.Map;

/**
 * @author yuisama
 * @date 2023/04/11 21:51
 **/
@Data
public class DocWeight {
    private String word;
    private int docId;
    private int weight;


    public DocWeight(String word, int docId, Map<String,Integer> countInTitle,Map<String,Integer> countInContent) {
        this.word = word;
        this.docId = docId;
        //权重按照： weight = 单词出现在标题的次数 *10 + 单词出现在正文的次数
        //相比较而言，
        //1.匹配程度越高（出现次数越多），权重越高，排名越靠前
        //2.出现在标题上的可能性比出现在正文的重要性高
        this.weight = countInTitle.getOrDefault(word,0) * 10 + countInContent.getOrDefault(word,0);
    }
}

